package classconverstation.cscl.ist.psu.edu.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnector {

	private static DBConnector connector;
	static {
		try {
			//new JDBCConnectionDriver("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/classconversation", "root", "123456");
			new JDBCConnectionDriver("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3326/class_conversation_db", "cc_admin", "cc_admin");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	private DBConnector() {}
	
	public static DBConnector getInstance() {
		if (connector == null) {
			connector = new DBConnector();
		}
		return connector;
	}
    public Connection getConnection() throws SQLException {
        return DriverManager.getConnection("jdbc:jdc:jdcpool");
    }
}
